package i18n.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class I18nController {
    @Autowired
    private MessageSource messageSource;

    @GetMapping("/username")
    public String getUsername() {
        return messageSource.getMessage("demo.i18n.username", null, LocaleContextHolder.getLocale());
    }
}
